package com.tzy.for10evalue.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.tzy.for10evalue.dao.TxTestMapper1;
import com.tzy.for10evalue.entity.txtest.TxTest1;
import com.tzy.for10evalue.service.TxTestService1;
import com.tzy.for10evalue.service.TxTestService2;
import com.tzy.for10evalue.service.TxTestService3;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author tzy
 * @date 2022/6/10 13:53
 */
@Service
@Slf4j
public class TxTestService1impl extends ServiceImpl<TxTestMapper1, TxTest1> implements TxTestService1 {
    @Autowired
    private TxTestService2 txTestService2;
    @Autowired
    private TxTestService3 txTestService3;

    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public boolean save() {
        String s = null;
        TxTest1 txTest1 = new TxTest1();
        txTest1.setName("txTest1");
        log.info("start");
        insert(txTest1);
        txTestService2.save();

        txTestService3.save();

/*        if (s == null) {
            throw new RuntimeException("出错了");
        }*/
        log.info("end");
        return false;
    }
}
